/********************************************/
  // Creation History
  // --------------------------------------------------------------
  //	Company:			HTHK
  //	NAME:				JobServlet.java
  //    Title   :			operate A Job Record such as:Create,Update,Delete
  //	FUNCTION:
  //	BY:					Jet Tao
  //	DATE:				28/08/2003
  // --------------------------------------------------------------
/*********************************************/

package tss.restrict;

import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
import java.sql.*;

import com.ffpc.sql.*;
import com.ffpc.struts.StrutsMessage;

import tss.common.DBServlet2;


public class RestrictServlet
  extends DBServlet2 {

  @Override
protected String perform(  HttpServletRequest request,
                             HttpServletResponse response,
                             StrutsMessage message)
    throws  ServletException,
            IOException,
            SQLException,
            DataException,
            Exception
  {
     //New A Form Action
     String action = new String(request.getParameter("formAction"));
     //New A Job Record
     RestrictBean Restrict=RestrictProcess.createBean();

     //Get A Job Record
     Restrict.setBefore_quantity(request.getParameter("restrict_bfquantity"));
     Restrict.setAfter_quantity(request.getParameter("restrict_afquantity"));
     Restrict.setUnit(request.getParameter("restrict_unit"));

     //Deal different operations
     //Insert
      //if (action.trim().equalsIgnoreCase("Create"))
      //{
        //Set Job's Create Date and Create By
        //Job.setCreate_date(DateFormatter.format(this.getDate()));
        //Job.setCreate_by(getUser().getUser_name());
        //if (JobProcess.insert(this.getConnection(),Job)>0)
            //message.setMessage("Save successfully.");
        //else
            //message.setMessage("Save failure");
      //}
      //Update
      //else if (action.trim().equalsIgnoreCase("Update"))
      if (action.trim().equalsIgnoreCase("Update"))
      {
        //Set Job's Update Date and Update By
        //Restrict.setUpd_date(DateFormatter.format(this.getDate()));
        //Job.setUpd_by(getUser().getUser_name());
        if (RestrictProcess.update(this.getConnection(), Restrict) > 0)
          message.setMessage("Save successfully.");
        else
          message.setMessage("Save failure.");
      }
      //Delete
      //else if (action.trim().equalsIgnoreCase("Delete"))
        //if (JobProcess.delete(this.getConnection(),Job)>0)
            //message.setMessage("Delete successfully.");
        //else
            //message.setMessage("Delete failure.");
      else
            message.setMessage("No action mapped!");

      return "tss/restrict/Restrict.jsp";
  }
}


